package routers

import (
	"api_admin_server/internal/controllers"
	"api_admin_server/internal/middleware"
	"github.com/gin-gonic/gin"
)

func RegisteAuth(engine *gin.Engine) {
	openApi := engine.Group("open")
	authController := controllers.AuthControoler{}
	openApi.POST("/user/login", authController.Login) //登录

	authApi := engine.Group("auth").Use(middleware.VerifyToken())
	authApi.GET("/user/role", authController.GetUserRole)
	authApi.POST("/user/logout", authController.Logout)
	authApi.POST("/user/disabled", authController.DisabledUser)
	authApi.POST("/user/create", authController.CreateUser)
	authApi.POST("/user/update", authController.UpdateUser)
	authApi.POST("/user/password/reset", authController.ResetPassword)
	authApi.POST("/user/role/give", authController.GiveUserRole)
	authApi.GET("/user/list", authController.GetUserList)
	authApi.GET("/user/permission", authController.GetUserPermission)
	authApi.GET("/role/list", authController.GetRoleList)                        //角色列表
	authApi.POST("/role/delete", authController.DeleteRole)                      //删除角色
	authApi.POST("/role/create", authController.CreateRole)                      //新建角色
	authApi.POST("/role/update", authController.UpdateRole)                      //更新角色
	authApi.GET("/role/permission/list", authController.GetPermissionListByRole) //角色的权限
	authApi.POST("/role/permission/give", authController.GiveRolePermission)     //角色的权限赋予
	authApi.GET("/permission/list", authController.GetPermissionList)
}
